import 'package:mziot/app/config/api.dart';
import 'package:mziot/app/data/public_model.dart';
import 'package:mziot/app/data/scene_info_entity.dart';
import 'package:mziot/app/data/scene_list_entity.dart';
import 'package:mziot/app/data/scene_params_entity.dart';
import 'package:mziot/app/tools/public_provider.dart';

class SceneProvider {
  //场景列表
  Future<BaseModel<List<SceneListEntity>>> takeSceneList() {
    return PublicProvider.request<List<SceneListEntity>>(path: Api.sceneList);
  }

  //场景详情 sceneId
  Future<BaseModel<SceneInfoEntity>> takeSceneInfo(int sceneId) {
    return PublicProvider.request<SceneInfoEntity>(
        path: Api.sceneDetail, params: {'sceneId': sceneId});
  }

  //锁定场景 sceneId isLock
  Future<BaseModel<dynamic>> lockScene(int sceneId, bool lock) {
    return PublicProvider.request<dynamic>(
        path: Api.sceneLock, params: {'sceneId': sceneId, 'isLock': lock});
  }

  //添加/更新场景
  Future<BaseModel<dynamic>> editScene(SceneParamsEntity entity) {
    final params = entity.toJson();
    return PublicProvider.request<dynamic>(path: Api.sceneEdit, params: params);
  }

  //场景开关sceneId switchStatus
  Future<BaseModel<dynamic>> turnScene(int sceneId, bool turn) {
    return PublicProvider.request<dynamic>(
        path: Api.sceneTurn, params: {'sceneId': sceneId, 'switchStatus': turn});
  }

  //场景删除 sceneId
  Future<BaseModel<dynamic>> deleteScene(int sceneId) {
    return PublicProvider.request<dynamic>(path: Api.sceneDelete, params: {'sceneId': sceneId});
  }
}
